/**
 * 公用参数
 */
var hostcode=''


/**
 * 默认加载
 * @type {{init: Window.process.init, public: Window.process.public}}
 */
window.process = {
    init: function () {
        this.initData();
       
    },
    initData() {
        var paramsData = getUrlParamsCode();
        hostcode= paramsData['hostcode']?paramsData['hostcode']:'';
        this.load(hostcode);

    },
    load(search){
        let api='/appZdDepts/find'
        let data={
            hostcode:search
        }
        postAjax(api,data,this.callbackLoad,this) 
    },
    callbackLoad(data,that){
        var temp=[]  
        for(var i=0;i<data.length;i++){
            if(data[i]['pcode']==null){
                temp.push(data[i])
             
            } 
        }
        for(var j=0;j<temp.length;j++){
           temp[j]['data']=[]
            for(var i=0;i<data.length;i++){
                if(temp[j].code==data[i].pcode){
                    temp[j]['data'].push(data[i])
                }
            }
        }
        var Data={
            list:temp
        };
        var listHtml = template('list_data', Data);
        $("#list_data_content").html(listHtml);
        that.public();
    },
    public() {
        $('.tabList').eq(0).show();
        //tab切换
        $('.tabBar li').click(function () {
            var index=$(this).index()
            $(this).addClass('on').siblings().removeClass('on');
            $('.tabList').hide()
            $('.tabList').eq(index).show()
        });

        //选中内容
        $('.tabList li').click(function () {
            var name=$(this).text();
            var code=$(this).attr('data-code')
            var pcode=$(this).attr('data-pcode')
            var hostcode=$(this).attr('data-hostcode')
            $(this).addClass('on').siblings().removeClass('on');
            window.location.href = 'make_list.html?name='+name+'&code='+code+'&pcode='+pcode+'&hostcode='+hostcode;
        });

    }
};

/**
 * 启动方法执行
 */
process.init();



